package cn.jhc.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.bean.Title;
import cn.jhc.dao.DaoType;
import cn.jhc.dao.TitleDAO;
import cn.jhc.factory.DAOFactory;

/**
 * Servlet implementation class ShowBookServlet
 */
@WebServlet("/show.do")
public class ShowBookServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
//		TitleDAO dao = new TitleDAO();
		String isbn = req.getParameter("isbn");
		TitleDAO dao = (TitleDAO)DAOFactory.getDao(DaoType.TITLE);
		Title title = dao.findByIsbn(isbn);
		req.getSession().setAttribute("title", title);
		req.getRequestDispatcher("/book.jsp").forward(req, resp);
	}

}
